package com.example.administrator.maizuofilm.notshow;

import android.util.Log;

import com.example.administrator.maizuofilm.bean.NotShow;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.EventBusBuilder;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Created by Administrator on 2016/7/12.
 */
public class NotShowPresenter implements NotShowContract.NotShowPresenter<NotShowContract.NotShowModel, NotShowContract.NotShowView> {
    private NotShowContract.NotShowModel notShowModel;
    private NotShowContract.NotShowView notShowView;
    int temp;
    public NotShowPresenter(NotShowContract.NotShowModel notShowModel, NotShowContract.NotShowView notShowView) {
        this.notShowModel = notShowModel;
        this.notShowView = notShowView;
        EventBus.getDefault().register(this);

    }
    @Override
    public void init(int index) {
        notShowModel.init(index);
    }

    @Subscribe(threadMode = ThreadMode.BACKGROUND)
    public void index(int index){
        temp=index;
        Log.i("tag", "index: "+temp);
        notShowModel.init(temp);

    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void sub(NotShow notShow) {
        if (notShow == null) {
            notShowView.onInitFail("失败");
        } else {
                notShowView.onInitSuccess(notShow);
        }
    }
}
